feat(forge): add --rerun-failed flag to watch mode for faster TDD feedback #11993
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
When developing with
forge test --watch
, running all tests on every file change can be slow . Adds a--rerun-failed
flag that automatically reruns only previously failed tests when files change, falling back to normal watch behavior once failures are resolved.The flag use the existing test failure tracking mechanism (cache/test-failures file) when tests fail. When enabled, watch mode checks if this file exists and automatically adds
--rerun
to the command, otherwise it proceeds with the standard file-based test filtering.For example, in a project with 80 tests where 3 are failing, this reduces iteration time from ~2 minutes to ~6 seconds per change, making watch mode practical for TDD workflows where you're iterating on fixing specific test failures.
Usage:
forge test --watch --rerun-failed